<template>
  <a-drawer v-model:visible="visible" title="测试任务详情" :width="width >= 600 ? 600 : '100%'" :footer="false">
    <a-descriptions :column="2" size="large" class="general-description">
      <a-descriptions-item label="ID">{{ dataDetail?.id }}</a-descriptions-item>
      <a-descriptions-item label="任务名称">{{ dataDetail?.name }}</a-descriptions-item>
      <a-descriptions-item label="备注">{{ dataDetail?.mark }}</a-descriptions-item>
      <a-descriptions-item label="项目ID">{{ dataDetail?.projectId }}</a-descriptions-item>
      <a-descriptions-item label="设备ID">{{ dataDetail?.deviceId }}</a-descriptions-item>
      <a-descriptions-item label="计划开始时间">{{ dataDetail?.planStartTime }}</a-descriptions-item>
      <a-descriptions-item label="计划结束时间">{{ dataDetail?.planEndTime }}</a-descriptions-item>
      <a-descriptions-item label="实际开始时间">{{ dataDetail?.actualStartTime }}</a-descriptions-item>
      <a-descriptions-item label="实际结束时间">{{ dataDetail?.actualEndTime }}</a-descriptions-item>
      <a-descriptions-item label="状态">{{ dataDetail?.status }}</a-descriptions-item>
      <a-descriptions-item label="测试模板ID">{{ dataDetail?.templateId }}</a-descriptions-item>
      <a-descriptions-item label="创建人">{{ dataDetail?.createUser }}</a-descriptions-item>
      <a-descriptions-item label="创建人">{{ dataDetail?.createUserString }}</a-descriptions-item>
      <a-descriptions-item label="创建时间">{{ dataDetail?.createTime }}</a-descriptions-item>
      <a-descriptions-item label="修改人">{{ dataDetail?.updateUser }}</a-descriptions-item>
      <a-descriptions-item label="修改人">{{ dataDetail?.updateUserString }}</a-descriptions-item>
      <a-descriptions-item label="修改时间">{{ dataDetail?.updateTime }}</a-descriptions-item>
    </a-descriptions>
  </a-drawer>
</template>

<script setup lang="ts">
import { useWindowSize } from '@vueuse/core'
import { type InfoDetailResp, getInfo as getDetail } from '@/apis/task/info'

const { width } = useWindowSize()

const dataId = ref('')
const dataDetail = ref<InfoDetailResp>()
const visible = ref(false)

// 查询详情
const getDataDetail = async () => {
  const { data } = await getDetail(dataId.value)
  dataDetail.value = data
}

// 打开
const onOpen = async (id: string) => {
  dataId.value = id
  await getDataDetail()
  visible.value = true
}

defineExpose({ onOpen })
</script>

<style scoped lang="scss"></style>
